#include <iostream>
#include "XJThreadSpecific.h"
#include "XJThreadManager.h"
#include <unistd.h>


typedef XJUtilClass::XJThreadSpecific<int> xjts_int;
typedef XJUtilClass::XJThreadSpecific<std::string> xjts_str;
typedef XJUtilClass::XJThreadManager::XJThreadRunState XJThreadRunState;
int thread_fun_1(XJThreadRunState, void *);
int thread_fun_2(XJThreadRunState, void *);
int main(int argc, char *argv[]){
	xjts_int::init();
	xjts_str::init();
	xjts_int::set(new int (0));
	xjts_str::set(new std::string("hello world"));
	XJUtilClass::XJThreadManager *tm= XJUtilClass::XJThreadManager::instance();

	int *p = xjts_int::get();
	std::cout << *p << std::endl;
	std::cout << *xjts_str::get() << std::endl;
	tm->spawn(thread_fun_1);
	tm->spawn(thread_fun_2);
	sleep(10);
	tm->exit_all();
	tm->wait_all(10);
	xjts_int::destroy();
	xjts_str::destroy();
	return 0;
}

